<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ include file="/WEB-INF/component/commonTagLib.jsp" %>

<!DOCTYPE html>
<html>
<head>
<title>选择企业</title>
<%@ include file="/WEB-INF/component/commonCSS.jsp"%>
</head>
<body class="skin-blue-light sidebar-mini fixed skin-blue-light-frame">

	<section class="content">
		<div class=" box box-success">
			<div class="box-body">
				<div class="input">
					<div class="textalign1"><spring:message code="message.lable.qiYeMingCheng"/><spring:message code="message.yanZheng.maoHao"/></div> 
                        <div class="boxinput">
                        <input type="text" class="textinput" id="compName" placeholder="<spring:message code="message.lable.qiYeMingCheng"/>" />
                    	</div>
                    	
                	<div class="textalign1"><spring:message code="message.lable.qiYeBianMa"/><spring:message code="message.yanZheng.maoHao"/></div> 
                        <div class="boxinput">
                        <input type="text" class="textinput" id="compCode" placeholder="<spring:message code="message.lable.qiYeBianMa"/>" />
                   		</div>
					<div class="textalign1" >
					<button type="button" onclick="likeQuery();" class="btn btn-success btn-sm" id="selectDrug"><spring:message code="message.button.seachSpacing"/></button>
					</div>
				  </div>
			</div>
		</div>
		<table class="jqgrid" id="gridlist"></table>
		<div id="gridpage"></div>
		 <div class=" box box-warning bottongroup">
            <button type="button" id="confirm"  onclick="confirm();" class="btn btn-default btn-sm"><spring:message code="message.button.okSpacing"/></button>
        </div>
     </section>   
	<%@ include file="/WEB-INF/component/commonJS.jsp"%>
	<script type="text/javascript">
	
	//绑定回车
    $('#compCode,#compName,#area1,#area2,#area3').bind('keydown', function(event) {
        if (event.keyCode == "13") {        //13 位电脑上回车键的位置代码
            $('#selectDrug').click();
        }
    }); 
  
    $("#compName").focus();//加载页面光标在第一个查询框内 
    
		$(function() {
			  $("#area1").HNSelect({
		            url: "${pageContext.request.contextPath}/selectController/getArea.html", data: { ID: '000000' },  defaultText: "<option value=''><spring:message code="message.select.option"/></option>",
		            func: function () {
		                $("#area2").HNSelect({
		                    parent_selector: "#area1", url: "${pageContext.request.contextPath}/selectController/getArea.html", dataid: "ID",defaultText: "<option value='' ><spring:message code="message.select.option"/></option>",
		                    		  func: function () {
		                                  $("#area3").HNSelect({
		                                      parent_selector: "#area2", url: "${pageContext.request.contextPath}/selectController/getArea.html", dataid: "ID", defaultText: "<option value=''><spring:message code="message.select.option"/></option>"
		                                  });
		                              }
		                });
		            }
		        });

			  
			$("#gridlist").jqGrid({
								url : "${ctx}/stdProdDrugInfo/getSelectProdComp.html",
								mtype : "POST",
								datatype : "json",
								autowidth : true,
								height : 270,
								colNames : [ 
								             'id',
								             'areaId', 
								             '<spring:message code="message.lable.qiYeBianMa"/>', 
								             '<spring:message code="message.lable.qiYeMingCheng"/>', 
								             '<spring:message code="message.lable.suoShuDiQu"/>'
								             ],
								colModel : [
								            {name : 'prodCompId',width : 100,align : "center",hidden : true,sortable : false},
								            {name : 'areaId',width : 100,align : "center",hidden : true,sortable : false},
											{name : 'prodCompCode',width : 80,align : "center",sortable : false},
										    {name : 'prodCompName',width : 160,align : "left",sortable : false},
										    {name : 'arFullname',width : 100,align : "left",sortable : false}
										
										 ],
								rowNum : 20,
								rowList : [ 10, 20, 50,100 ],
								rownumbers : true,
								pager : "#gridpage",
								viewrecords : true,
								caption : "<spring:message code="message.lable.qiYeXinXiChaKan"/>",
								jsonReader : {
									repeatitems : false,
									id : "ids"
								},
								gridComplete:function(){
			                        //序号列宽度自适应（参数为jqgridID）
			                        autoRNWidth("gridlist");
			                        //数据只有一条时默认选中（参数为jqgridID）
			                        selectByOneData("gridlist");
			                    },
				                /* gridComplete:function(){        
				                    var page = $("#gridlist").jqGrid('getGridParam','page');
				                    var rows = $('#gridlist').getGridParam("rowNum");
				                    var maxnum = (rows*page).toString();
				                    var len = (maxnum.length)*10;
				                    $('.jqgfirstrow').find('td').eq(0).css('width',len+'px');
				                    $('#gridlist_rn').css('width',len+'px');
				                    
				                    selectByOneData("gridlist");
				                } */
							});
			$("#gridlist").jqGrid('navGrid', '#gridpage', {
				add : false,
				edit : false,
				del : false,
				search : false,
				refresh : false
			});

			 $(window).trigger("resize");
		});


		function likeQuery() {
			var areaId = "";
			if( "" != $("#area1").val() ){
				areaId = $("#area1").val();
			}
			if( "" != $("#area2").val()){
				areaId = $("#area2").val();
			}
			if( "" != $("#area3").val()){
				areaId = $("#area3").val();
			}

			
			var code = $("#compCode").val();
			var compName = $("#compName").val();
		
			$("#gridlist").jqGrid('setGridParam',{
				       	    	datatype:'json',
				                postData:{
				                	"areaId":areaId,
				                	"prodCompCode":code,
				                	"prodCompName":compName
				                	},
				                page : 1
			}).trigger("reloadGrid");
		}
		
        function CurentTime(now)  
    	{       	         
    	    var year = now.getFullYear();   
    	    var month = now.getMonth() + 1; 
    	    var day = now.getDate();     
    	         
    	    var hh = now.getHours();       
    	    var mm = now.getMinutes(); 
    	    var ss=now.getSeconds(); 
    	    var clock = year + "-"; 
    	    if(month < 10) clock += "0";         
    	    clock += month + "-";  
    	    if(day < 10) clock += "0";   
    	    clock += day + " "; 
    	    if(hh < 10) clock += "0";  
    	    clock += hh + ":";  
    	    if (mm < 10) clock += '0';   
    	    clock += mm+ ":";  
    	    if (ss < 10) clock += '0';   
    	    clock += ss;  
    	    return(clock);   
    	}
        
        //确认
        function confirm() {
            var rowId = $("#gridlist").jqGrid("getGridParam", "selrow") || [];
             if(rowId.length <=0){
                $.HN.message.alert("<spring:message code="message.list.qingXuanZeYaoQueRenQiYe"/><spring:message code="message.yanZheng.ganTanHao"/>", "<spring:message code="message.HN.alert.type"/>", "warn");
                return;
             }
             var rowdata = $("#gridlist").jqGrid('getRowData', rowId);
             var dialog = top.dialog.get(window);
             var params = {
             	"prodCompName" : rowdata.prodCompName,
             	"prodCompId" : rowdata.prodCompId,
             	"prodCompCode" : rowdata.prodCompCode,
             	"prodCompStatus" : 1
             };
             dialog.close(params);   // 关闭（隐藏）对话框
             dialog.remove();        // 主动销毁对话框
        }

      
	</script>
</body>
</html>









